<?php
abstract class Bgtask_Storage{
    /**
     * Get current task list
     * @return array
     */
    abstract public function getList();
    /**
     * Get Task info by Id
     * @param integer $pid
     * @return array
     */
    abstract public function get($pid);
    /**
     * Send signal
     * @param integer $pid
     * @param integer $signal - const
     * @return void
     */
    abstract public function signal($pid , $signal);
    /**
     * Kill task
     * @param integer $pid
     * @return void
     */
    abstract public function kill($pid);
    /**
     * Get task signals
     * @param integer $pid
     * @param boolean $clean - remove signals after reading
     * @return array();
     */
    abstract public function getSignals($pid , $clean = false);
    /**
     * Remove signals
     * @param integer $pid
     * @param array $sigId - optional
     * @return array
     */
    abstract public function clearSignals($pid , $sigId = false);
    /**
     * Update task state
     * @param integer $pid
     * @param integer $memory - memory allocated
     * @param integer $opTotal
     * @param integer $opFinished
     * @param integer $status
     */
    abstract public function updateState($pid  ,$opTotal, $opFinished , $status , $memoryPeak , $memoryAllocated);    
    /**
     * Teminate process
     */
    protected function _terminate(){
    	/**
    	 * @todo log termination
    	 */
    	exit();
    }
    /**
     * Check task record
     * @param integer $pid
     * @return boolean
     */
    abstract public function isLive($pid);
    /**
     * Set task finished
     * @param integer $pid
     * @param string $time
     */
    abstract public function setStarted($pid , $time);
    /**
     * Set task finished
     * @param integer $pid
     * @param string $time
     */
    abstract public function setFinished($pid , $time);
    /**
     * Set task stopped
     * @param integer $pid
     * @param string $time
     */
    abstract public function setStoped($pid , $time);
    /**
     * Add task record
     * @param string $description
     * @return inter  - task pid
     */
    abstract public function addTaskRecord($description);
}